//依赖倒置原则
//依赖抽象 而非依赖具体实现
interface Girlfriend {
  name: string;
  age: number;
  cook(): void;
};

class Merry implements Girlfriend {
  name: string = 'merry1';
  age: number = 20;
  cook(): void{
    console.log(this.name+'会做饭')
  }
};
class Luncy implements Girlfriend {
  name: string = 'lucy1';
  age: number = 23;
  cook(): void{
    console.log(this.name+'会做饭')
  }
};

class  Boyfriend {
  constructor(public girlfriend:Girlfriend) {
    
  }
};

let boy1 = new Boyfriend(new Merry());
let boy2 = new Boyfriend(new Luncy());
boy1.girlfriend.cook();
boy2.girlfriend.cook();